package org.smart4j.aopdemo.spring;

import org.smart4j.aopdemo.simple.Greeting;
import org.smart4j.aopdemo.simple.GreetingImpl;
import org.springframework.aop.framework.ProxyFactory;

/**
 * 使用Spring AOP编程
 */
public class AOPClient {

    public static void main(String[] args){
        ProxyFactory factory = new ProxyFactory();
        factory.setTarget(new GreetingImpl());
        //1.-- 使用前后增强
//        factory.addAdvice(new GreetingBeforeAdvice());
//        factory.addAdvice(new GreetingAfterAdvice());
        //2.-- 使用环绕增强
        factory.addAdvice(new GreetingAroundAdvice());
        Greeting greeting = (Greeting) factory.getProxy();
        greeting.sayHello("liuzx");
    }

}
